In [1]:
    
%matplotlib inline
    
In [2]:
    
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
from django.contrib.gis.measure import D
from rw import database
db = database()
    
In [3]:
    
dates = ('2014-10-19', '2013-05-04', '2012-10-21', '2012-05-05', '2011-10-16',
         '2010-10-17', '2010-05-01', '2009-10-18')
races = {date: db.get_race_by_date(date).tcx for date in dates}
len(races)
    
    
    Out[3]:
In [4]:
    
fig, ax = plt.subplots()
for name in sorted(races):
    m = races[name]
    ax.plot(m.longitude, m.latitude)
ax.legend(dates, loc='best')
fig.set_size_inches(12, 12)
    
    
In [5]:
    
fig, ax = plt.subplots()
names = ['2014-10-19', '2012-10-21', '2011-10-16', '2010-10-17', '2009-10-18']
for name in names:
    m = races[name]
    limited = m[m.distance < D(mi=13.3).m]
    ax.plot(limited.longitude, limited.latitude)
ax.legend(names, loc='best')
fig.set_size_inches(12, 12)